//
//  YGFoodWekipediaTableViewCell.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/4/25.
//

#import "YGFoodWekipediaTableViewCell.h"


@interface YGFoodWekipediaTableViewCell ()

@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailLabel;






@end

@implementation YGFoodWekipediaTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
        [self initconstraints];
    }
    return self;
}

-(void)initView{
    [self.contentView addSubview:self.imgView];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.detailLabel];
    
    
    
}

-(void)initconstraints{
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.mas_equalTo(self.contentView).offset(10);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-10);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(100);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.imgView.mas_top);
            make.left.mas_equalTo(self.imgView.mas_right).offset(10);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(15);
    }];
    
    [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
            make.left.mas_equalTo(self.titleLabel.mas_left);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-10);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-20);
    }];
}
//列表数据
-(void)configureData:(YGFoodWikipediaTableArrayModel *)model{
    
    if (model) {
        NSString *imgUrl =model.thumbnail;
        NSURL *url = [NSURL URLWithString:imgUrl];
        [_imgView sd_setImageWithURL:url];
        
        NSString *title = model.name;
        _titleLabel.text =title;
        
        NSString *detail = model.content;
        _detailLabel.text =detail;
    }
 
}


#pragma setter
- (UIImageView *)imgView{
    if (!_imgView) {
        _imgView = [[UIImageView alloc]init];
        _imgView.layer.cornerRadius=8;
        _imgView.clipsToBounds = YES;
    }
    return _imgView;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13] ;
        _titleLabel.textColor = UIColorFromRGB(0x333333);
        
    }
    return _titleLabel;
}
- (UILabel *)detailLabel{
    if (!_detailLabel) {
        _detailLabel = [[UILabel alloc]init];
        _detailLabel.font = [UIFont systemFontOfSize:12];
        _detailLabel.textColor = UIColorFromRGB(0x333333);
        _detailLabel.numberOfLines = 0;
    }
    return _detailLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
